package com.hg.oa.module.calendar.presenter;

import android.content.Context;
import android.support.v4.app.FragmentTransaction;
import android.transition.Slide;
import android.view.Gravity;

import com.hg.oa.R;
import com.hg.oa.common.BasePresenterImpl;
import com.hg.oa.module.calendar.layer.ApplyDayReportFragment;
import com.hg.oa.module.calendar.layer.ApplyLevelFragment;

/**
 * Created by fengxiang on 2016/9/9.
 */
public class CalendarPressenter extends BasePresenterImpl {

    public CalendarPressenter(Context context) {
        super(context);
    }

    /**
     * 切换填写日报fragment
     *
     * @param id
     * @param fragmentTransaction
     * @return
     */
    public ApplyDayReportFragment applyDayReport(int id, FragmentTransaction fragmentTransaction) {
        Slide slideTransition = new Slide(Gravity.LEFT);
        slideTransition.setDuration(context.getResources().getInteger(R.integer.anim_duration_medium));
        ApplyDayReportFragment fragment = new ApplyDayReportFragment();
        fragment.setEnterTransition(slideTransition);
        fragment.setAllowEnterTransitionOverlap(true);
        fragment.setAllowReturnTransitionOverlap(true);
        fragmentTransaction.replace(id, fragment);
        fragmentTransaction.commit();
        return fragment;
    }


    /**
     * 切换请假日报fragment
     *
     * @param id
     * @param fragmentTransaction
     * @return
     */
    public ApplyLevelFragment applyLevelReport(int id, FragmentTransaction fragmentTransaction) {
        Slide slideTransition = new Slide(Gravity.RIGHT);
        slideTransition.setDuration(context.getResources().getInteger(R.integer.anim_duration_medium));
        ApplyLevelFragment fragment = new ApplyLevelFragment();
        fragment.setEnterTransition(slideTransition);
        fragment.setAllowEnterTransitionOverlap(true);
        fragment.setAllowReturnTransitionOverlap(true);
        fragmentTransaction.replace(id, fragment);
        fragmentTransaction.commit();
        return fragment;
    }

}
